namespace C1.Win.C1FlexGrid
{
    using C1.Win.C1FlexGrid.Util.Styles;
    using System;
    using System.Drawing;

    public class OwnerDrawCellEventArgs : EventArgs
    {
        internal CellStyle _cellStyle;
        internal bool _dirty;
        internal System.Drawing.Image _image;
        internal string _text;
        internal C1FlexGridBase _view;
        public readonly Rectangle Bounds;
        public readonly int Col;
        public readonly System.Drawing.Graphics Graphics;
        public bool Handled;
        public readonly int Row;

        internal OwnerDrawCellEventArgs(C1FlexGridBase view, System.Drawing.Graphics g, int row, int col, CellStyle s, Rectangle rc, string text, System.Drawing.Image img)
        {
            this._view = view;
            this.Graphics = g;
            this.Row = row;
            this.Col = col;
            this.Bounds = rc;
            this.Handled = false;
            this._cellStyle = s;
            this._text = text;
            this._image = img;
            this._dirty = false;
        }

        public void DrawCell()
        {
            this.DrawCell(DrawCellFlags.All);
        }

        public void DrawCell(DrawCellFlags flags)
        {
            C1.Win.C1FlexGrid.Util.Styles.Style style = this._cellStyle._style;
            bool flag = false;
            C1.Win.C1FlexGrid.Util.Styles.Style styleDisplay = this._view.GetStyleDisplay(this.Row, this.Col);
            C1.Win.C1FlexGrid.Util.Styles.Style parent = style.GetParent();
            if (!styleDisplay.Equals(style) && !styleDisplay.Equals(parent))
            {
                flag = true;
                style.SetParent(styleDisplay, false);
            }
            this._view.DrawCellBase(this.Graphics, this.Row, this.Col, style, this.Bounds, this.Text, this.Image, flags);
            this.Handled = true;
            if (flag)
            {
                style.SetParent(parent, false);
            }
        }

        public System.Drawing.Image Image
        {
            get
            {
                return this._image;
            }
            set
            {
                this._image = value;
                this._dirty = true;
            }
        }

        public CellStyle Style
        {
            get
            {
                return this._cellStyle;
            }
            set
            {
                this._cellStyle = value;
                this._dirty = true;
            }
        }

        public string Text
        {
            get
            {
                return this._text;
            }
            set
            {
                this._text = value;
                this._dirty = true;
            }
        }
    }
}

